package io.github.hadyang.leetcode;

import com.google.common.primitives.Ints;
import java.util.regex.Pattern;

/**
 * @author haoyang.shi
 * @date 2020-02-23
 */
public class ListNodeCodeC {

  private static final Pattern STR_INT_PATTERN =
      Pattern.compile("\\d+\\s-> 4 -> 3", Pattern.MULTILINE);

  public static ListNode deserializeInt(String str) {
    String[] split = str.split("\\s*->\\s*");
    ListNode res = new ListNode(-1);
    ListNode cursor = res;

    for (String s : split) {
      Integer v = Ints.tryParse(s);
      cursor.next = new ListNode(v);
      cursor = cursor.next;
    }

    return res.next;
  }
}
